﻿using System.Collections.Generic;
using Core.Library;

namespace Core.AdminGroupMenuPermission
{
    public class AdminGroupMenuPermissionController
    {
        public static string CheckActionPermission(int adminUserId, int adminMenuId)
        {
            var permission = string.Empty;
            var adminGroupMenuPermission = AdminGroupMenuPermission_GetBy_AdminUserId_AdminMenuId(adminUserId, adminMenuId);

            if (adminGroupMenuPermission.Count > 0)
                foreach (var agmp in adminGroupMenuPermission)
                {
                    permission += StatusHelper.IsChecked(agmp.Status, StatusHelper.IsPublished) ? "1" : "0";
                    permission += StatusHelper.IsChecked(agmp.Status, StatusHelper.IsReturned) ? "1" : "0";                    
                }
            else
                permission = "000";

            return permission;
        }

        public static List<AdminGroupMenuPermissionObject> AdminGroupMenuPermission_GetByAdminGroupId(int adminGroupId)
        {
            return ObjectHelper.FillCollection<AdminGroupMenuPermissionObject>(
                    AdminGroupMenuPermissionDAL.AdminGroupMenuPermission_GetByAdminGroupId(adminGroupId));
        }

        public static List<AdminGroupMenuPermissionObject> AdminGroupMenuPermission_GetBy_AdminUserId_AdminMenuId(int adminUserId, int adminMenuId)
        {
            return ObjectHelper.FillCollection<AdminGroupMenuPermissionObject>(
                    AdminGroupMenuPermissionDAL.AdminGroupMenuPermission_GetBy_AdminUserId_AdminMenuId(adminUserId, adminMenuId));
        }

        public static AdminGroupMenuPermissionObject AdminGroupMenuPermission_GetByAdminGroupIdAdminMenuId(int adminGroupId, int adminMenuId)
        {
            return ObjectHelper.FillObject<AdminGroupMenuPermissionObject>(
                    AdminGroupMenuPermissionDAL.AdminGroupMenuPermission_GetByAdminGroupIdAdminMenuId(adminGroupId, adminMenuId));
        }

        public static void AdminGroupMenuPermission_Create(AdminGroupMenuPermissionObject o)
        {
            AdminGroupMenuPermissionDAL.AdminGroupMenuPermission_Create(o);
        }

        public static void AdminGroupMenuPermission_Delete(int adminGroupId)
        {
            AdminGroupMenuPermissionDAL.AdminGroupMenuPermission_Delete(adminGroupId);
        }
    }
}
